package com.jqq.set_;

import java.util.LinkedHashSet;
import java.util.Set;

/**
 * @author 姬倩倩
 * @version 1.0
 */
@SuppressWarnings({"all"})
public class LinkedHashSetSource {
    public static void main(String[] args) {
        Set set = new LinkedHashSet();
        set.add(new String("AA"));
        set.add(456);
        set.add(456);
        set.add(new Customer("刘",1001));
        set.add(123);
        set.add("HSP");
        System.out.println("set="+set);
        //1.LinkedHashSet加入顺序和取出元素的顺序一致
        //2.LinkedHashSet底层是LinkedHashMap(是HashMap的子类)
        //3.底层结构(数组+双向链表)
        //4.第一次添加时，直接将table扩容到16，存放的结点类型是LinkedHashMap$Entry
        //5.数组是HashMap$Node[] 存放的元素/数据是LinkedHashMap$Entry类型
        /*
        //继承关系是在内部类完成的
         static class Entry<K,V> extends HashMap.Node<K,V> {
            Entry<K,V> before, after;
            Entry(int hash, K key, V value, Node<K,V> next) {
                super(hash, key, value, next);
        }
    }
         */
    }
}
class Customer{
    private String name;
    private int n;

    public Customer(String name, int n) {
        this.name = name;
        this.n = n;
    }
}